package org.sc.learn.server.front.ctrl;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.sc.learn.server.front.model.User;
import org.sc.learn.server.front.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author qianwx
 */
@RestController
@RequestMapping("user")
public class UserCtrl {

  @Autowired
  private UserService userService;

  @PostMapping("register")
  @ApiOperation("用户注册")
  @ApiResponses({@ApiResponse(code = 200, message = "注册成功")})
  public User register(@RequestBody @ApiParam(name = "user", value = "用户信息") User user) {
    return userService.register(user);
  }

  @PostMapping("show")
  @ApiOperation("测试负载均衡")
  @ApiResponses({@ApiResponse(code = 200, message = "返回消息成功")})
  public String show() {
    return userService.show();
  }
}
